<template>
    <div class="sortable-list-demo">
        <h2>排序组件示例</h2>

        <div class="demo-grid">
            <!-- 操作系统统计 -->
            <div class="demo-item">
                <SortableList title="操作系统" :items="osData" :maxItems="5" defaultSort="desc" />
            </div>

            <!-- 浏览器统计 -->
            <div class="demo-item">
                <SortableList title="访问浏览器" :items="browserData" :maxItems="5" defaultSort="desc" />
            </div>

            <!-- 设备类型统计 -->
            <div class="demo-item">
                <SortableList title="设备类型" :items="deviceData" :maxItems="4" defaultSort="asc" />
            </div>

            <!-- 地区访问统计 -->
            <div class="demo-item">
                <SortableList title="地区访问" :items="regionData" :maxItems="6" defaultSort="desc" />
            </div>
        </div>
    </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { SortableList } from '@/components/charts'

// 操作系统数据
const osData = ref([
    {
        id: 1,
        name: 'Android',
        value: 67,
        description: '移动端操作系统',
        icon: 'Monitor',
        unit: '%',
        count: 2
    },
    {
        id: 2,
        name: 'Windows',
        value: 33,
        description: '桌面端操作系统',
        icon: 'Monitor',
        unit: '%',
        count: 1
    }
])

// 浏览器数据
const browserData = ref([
    {
        id: 1,
        name: 'Edge浏览器',
        value: 67,
        description: 'Microsoft Edge',
        iconUrl: 'https://cdn.jsdelivr.net/gh/devicons/devicon/icons/edge/edge-original.svg',
        unit: '%',
        count: 2
    },
    {
        id: 2,
        name: 'Chrome浏览器',
        value: 33,
        description: 'Google Chrome',
        iconUrl: 'https://cdn.jsdelivr.net/gh/devicons/devicon/icons/chrome/chrome-original.svg',
        unit: '%',
        count: 1
    }
])

// 设备类型数据
const deviceData = ref([
    {
        id: 1,
        name: '手机',
        value: 1200,
        description: '移动设备访问',
        icon: 'Iphone',
        unit: '次',
        count: 1200
    },
    {
        id: 2,
        name: '平板',
        value: 800,
        description: '平板设备访问',
        icon: 'Iphone',
        unit: '次',
        count: 800
    },
    {
        id: 3,
        name: '桌面',
        value: 600,
        description: '桌面设备访问',
        icon: 'Monitor',
        unit: '次',
        count: 600
    }
])

// 地区访问数据
const regionData = ref([
    {
        id: 1,
        name: '北京',
        value: 2500,
        description: '首都地区',
        unit: '次',
        count: 2500
    },
    {
        id: 2,
        name: '上海',
        value: 1800,
        description: '经济中心',
        unit: '次',
        count: 1800
    },
    {
        id: 3,
        name: '广州',
        value: 1200,
        description: '南方城市',
        unit: '次',
        count: 1200
    },
    {
        id: 4,
        name: '深圳',
        value: 1000,
        description: '科技城市',
        unit: '次',
        count: 1000
    },
    {
        id: 5,
        name: '杭州',
        value: 800,
        description: '互联网城市',
        unit: '次',
        count: 800
    },
    {
        id: 6,
        name: '成都',
        value: 600,
        description: '西南城市',
        unit: '次',
        count: 600
    }
])
</script>

<style scoped>
.sortable-list-demo {
    padding: 20px;
    background: #f7f8fa;
    min-height: 100vh;
}

.sortable-list-demo h2 {
    text-align: center;
    margin-bottom: 30px;
    color: #333;
    font-size: 24px;
}

.demo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 24px;
    max-width: 1200px;
    margin: 0 auto;
}

.demo-item {
    min-height: 300px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .demo-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .demo-item {
        min-height: 250px;
    }
}
</style>
